package com.example.dao;

import com.example.entity.Orders;
import com.example.entity.Params;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface OrdersDao extends Mapper<Orders> {

    /**
     * 根据用户ID查询订单（orders 表）
     */
    @Select("SELECT * FROM orders WHERE user_id = #{userId} ORDER BY order_date DESC")
    List<Orders> findByUserId(@Param("userId") Integer userId);

    /**
     * 根据订单状态查询
     */
    @Select("SELECT * FROM orders WHERE status = #{status} ORDER BY order_date DESC")
    List<Orders> findByStatus(@Param("status") String status);

    /**
     * 复合查询（时间段、价格区间、状态等）建议在 XML 中实现动态 SQL
     */
    List<Orders> findBySearch(@Param("params") Params params);
}
